<template>
</template>

<script setup>
import { ref, defineProps, getCurrentInstance } from "vue";
const { proxy } = getCurrentInstance();
import {
  onLaunch,
  onShow,
  onHide,
  onLoad,
  onShareAppMessage,
} from "@dcloudio/uni-app";
const code = ref("")
onLaunch((data) => {
  console.log("App Launch", data);
  code.value = data;

  const updateManager = uni.getUpdateManager();
  console.log('更新管理对象：', updateManager);
  updateManager.onCheckForUpdate((res) => {
    console.log('版本是否有更新：', res);
    if (res.hasUpdate) {
      updateManager.onUpdateReady((res) => {
        uni.showModal({
          title: '更新提示',
          content: '小程序新版本已经准备好，是否重启小程序更新？',
          success(res) {
            if (res.confirm) {
              updateManager.applyUpdate();
            }
          }
        });
      });
      updateManager.onUpdateFailed((res) => {
        uni.showModal({
          title: '更新提示',
          content: '检查到有新版本，但是更新下载失败，请检查您的网络设置～',
          success(res) {
            if (res.confirm) {
              updateManager.applyUpdate();
            }
          }
        });
      });
    }
  })
});
onShow(() => {
  console.log("App Show");
});
onHide(() => {
  console.log("App Hide");
});
onLoad(() => {
  wx.showShareMenu({
    withShareTicket: true,
    menus: ["shareAppMessage", "shareTimeline"],
  });
});
onShareAppMessage((res) => {
  if (res.from === "button") {
    console.log(res.target);
  }
  return {
    title: "荣耀之路",
    path: "/pages/index/index",
    mpId: "wx0ae1c7463138cd07",
  };
});

// export default {
//   onLaunch: function (data) {
//     console.log("App Launch",data);
//     this.modal.msg("请阅读《用户服务协议》和《隐私政策》并勾选")
//   },
//   onShow: function () {
//     console.log("App Show");
//   },
//   onHide: function () {
//     console.log("App Hide");
//   },
//   onLoad() {
//     wx.showShareMenu({
//       withShareTicket: true,
//       menus: ["shareAppMessage", "shareTimeline"],
//     });
//   },
//   onShareAppMessage(res) {
//     console.log(this, "thios");
//     if (res.from === "button") {
//       console.log(res.target);
//     }
//     return {
//       title: "荣耀之路",
//       path: "/pages/index/index",
//       mpId: "wx0ae1c7463138cd07",
//     };
//   },
// };
</script>

<style lang="scss">
@import "uview-plus/index.scss";
</style>

<style lang="less">
/*每个页面公共css */
@import url(static/style/common.less);
@import url(static/icon/iconfont.css);
</style>


